// @ts-check

const META_URL = 'https://pinia.vuejs.org'
const META_TITLE = 'Pinia 🍍'
const META_DESCRIPTION =
  'Intuitive, type safe, light and flexible Store for Vue'
const META_IMAGE = 'https://pinia.vuejs.org/social.png'

const isProduction = process.env.NODE_ENV

/**
 * @type {import('vitepress').UserConfig['head']}
 */
const productionHead = [
  [
    'script',
    {
      src: 'https://unpkg.com/thesemetrics@latest',
      async: '',
      type: 'text/javascript',
    },
  ],
]

/**
 * @type {import('vitepress').UserConfig}
 */
module.exports = {
  title: 'Pinia中文文档',
  lang: 'zh-CN',
  description: '用起来最舒服的 Vue Store',
  // 部署站点的基础路径
  base: '/docs-pinia-zh/',

  head: [
    ['link', { rel: 'icon', type: 'image/svg+xml', href: '/logo.svg' }],
    ['link', { rel: 'icon', type: 'image/png', href: '/logo.png' }],

    [
      'meta',
      { name: 'wwads-cn-verify', content: '5878a7ab84fb43402106c575658472fa' },
    ],

    [
      'meta',
      {
        property: 'og:type',
        content: 'website',
      },
    ],
    [
      'meta',
      {
        property: 'og:url',
        content: META_URL,
      },
    ],
    [
      'meta',
      {
        property: 'og:title',
        content: META_TITLE,
      },
    ],
    [
      'meta',
      {
        property: 'og:description',
        content: META_DESCRIPTION,
      },
    ],
    [
      'meta',
      {
        property: 'og:image',
        content: META_IMAGE,
      },
    ],
    [
      'meta',
      {
        property: 'twitter:card',
        content: 'summary_large_image',
      },
    ],
    [
      'meta',
      {
        property: 'twitter:url',
        content: META_URL,
      },
    ],
    [
      'meta',
      {
        property: 'twitter:title',
        content: META_TITLE,
      },
    ],
    [
      'meta',
      {
        property: 'twitter:description',
        content: META_DESCRIPTION,
      },
    ],
    [
      'meta',
      {
        property: 'twitter:image',
        content: META_IMAGE,
      },
    ],

    // [
    //   'link',
    //   {
    //     rel: 'preload',
    //     href: '/dank-mono.css',
    //     as: 'style',
    //     onload: "this.onload=null;this.rel='stylesheet'",
    //   },
    // ],

    ...(isProduction ? productionHead : []),
  ],

  themeConfig: {
    repo: 'vuejs/pinia',
    logo: '/logo.svg',
    // docsDir: 'packages/docs',
    docsBranch: 'v2',
    editLinks: true,

    // algolia: {
    //   appId: '69Y3N7LHI2',
    //   apiKey: '45441f4b65a2f80329fd45c7cb371fea',
    //   indexName: 'pinia',
    // },

    nav: [
      { text: '指南', link: '/zh/introduction' },
      { text: 'API', link: '/zh/api/' },
      // { text: 'Config', link: '/config/' },
      // { text: 'Plugins', link: '/plugins/' },
      {
        text: '相关链接',
        items: [
          {
            text: '论坛',
            link: 'https://github.com/vuejs/pinia/discussions',
          },
          {
            text: '聊天室',
            link: 'https://chat.vuejs.org',
          },
          {
            text: 'Twitter',
            link: 'https://twitter.com/posva',
          },
          {
            text: '更新日志',
            link: 'https://github.com/vuejs/pinia/blob/v2/packages/pinia/CHANGELOG.md',
          },
        ],
      },
    ],

    sidebar: {
      '/zh': [
        {
          text: '介绍',
          items: [
            {
              text: 'Pinia 是什么？',
              link: '/zh/introduction',
            },
            {
              text: '开始',
              link: '/zh/getting-started',
            },
          ],
        },
        {
          text: '核心概念',
          items: [
            { text: '定义一个 Store', link: '/zh/core-concepts/' },
            { text: 'State', link: '/zh/core-concepts/state' },
            { text: 'Getters', link: '/zh/core-concepts/getters' },
            { text: 'Actions', link: '/zh/core-concepts/actions' },
            { text: '插件', link: '/zh/core-concepts/plugins' },
            {
              text: '组件外的 Stores',
              link: '/zh/core-concepts/outside-component-usage',
            },
          ],
        },
        {
          text: '服务端渲染 (SSR)',
          items: [
            {
              text: 'Vue 与 Vite',
              link: '/zh/ssr/',
            },
            {
              text: 'Nuxt.js',
              link: '/zh/ssr/nuxt',
            },
          ],
        },
        {
          text: '手册',
          link: '/zh/cookbook/',
          items: [
            {
              text: '从 Vuex ≤4 迁移',
              link: '/zh/cookbook/migration-vuex',
            },
            {
              text: '热更新',
              link: '/zh/cookbook/hot-module-replacement',
            },
            {
              text: '测试',
              link: '/zh/cookbook/testing',
            },
            {
              text: '不使用 setup() 的用法',
              link: '/zh/cookbook/options-api',
            },
            {
              text: '组合式 Stores',
              link: '/zh/cookbook/composing-stores',
            },
            {
              text: '从 v0/v1 迁移至 v2',
              link: '/zh/cookbook/migration-v1-v2',
            },
          ],
        },
      ],
    }

  }
}
